<?php

namespace app\common\model;

use think\Model;
use traits\model\SoftDelete;

class Order extends Model
{

    // 表名
    protected $name = 'order';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    // 追加属性
    protected $append = [
    ];

    public function category()
    {
        return $this->belongsTo('Category', 'category_ids', 'id', [], 'LEFT')->setEagerlyType(0);
    }
    public function infos(): \think\model\relation\HasMany
    {
        return $this->hasMany('OrderInfo','order_id','id');
    }

    public function geCreatetimeAttr($value, $data)
    {
        return date('Y-m-d H:i:s',$value);
    }
}
